package com.langsin.crmpro.action;

import java.util.Map;

import com.langsin.crmpro.base.BaseAction;
import com.langsin.crmpro.manager.UserManager;
import com.langsin.crmpro.model.User;


public class UserAction extends BaseAction{
	
	private static final long serialVersionUID = -7065639424199382295L;
	
	private User user;
	private String verifyCode;
	private UserManager userManager;
	
	public String add() throws Exception {
		return null;
	}
	
	public String login() throws Exception
	{
		Boolean bln = this.userManager.checkUser(this.user.getUsername(), this.user.getPassword());
		if(bln)
		{
			String vcode = (String)this.getSession().get("validateCode");
			if(!vcode.toUpperCase().equals(this.verifyCode.toUpperCase())){
				this.addFieldError("verifyCode","验证码错误！");
				return this.INPUT;
		}
		this.getSession().put("user", user);
		return this.SUCCESS;
		}
		else
		{
			this.addFieldError("user.username","用户名或密码错误！");
			return this.INPUT;
		}
	}
	
	public String getVerifyCode()
	{
		return verifyCode;
	}

	public User getUser()
	{
		return user;
	}

	public void setUser(User user)
	{
		this.user = user;
	}

	public void setVerifyCode(String verifyCode)
	{
		this.verifyCode = verifyCode;
	}

	public void setUserManager(UserManager userManager) {
		this.userManager = userManager;
	}
	
}

